//
//  ListModel.m
//  MarianasTrench
//
//  Created by 付建国 on 16/3/17.
//  Copyright © 2016年 王爵. All rights reserved.
//

#import "ListModel.h"
#import "ExampleModel.h"

@implementation ListModel

- (void)setValue:(id)value forKey:(NSString *)key{
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"firstKResults"]) {
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            ExampleModel *model = [[ExampleModel alloc] init];
            [model setValuesForKeysWithDictionary:dic];
            
            [arr addObject:model];
            
            self.firstKResults = [NSArray arrayWithArray:arr];
        }
    }
    if ([key isEqualToString:@"list"]) {
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            ExampleModel *model = [[ExampleModel alloc] init];
            [model setValuesForKeysWithDictionary:dic];
            
            [arr addObject:model];
            
            self.list = [NSArray arrayWithArray:arr];
        }
    }    
    
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    if ([key isEqualToString:@"coverPathSmall"]) {
        self.coverSmall = value;
    }
}

@end
